import { http } from "@/utils/http";

// 模板列表/api/admin/config/price/user-template/list
export const getAdminTemplateList = (params?: {
  page: number;
  size: number;
  keyword?: string;
}) => {
  return http.request<any>(
    "get",
    "/api/admin/config/price/user-template/list",
    { params }
  );
};
// 创建模板头/api/admin/config/price/user-template/create-head
export const createAdminTemplateHead = (data: {
  title: string;
  description?: string;
}) => {
  return http.request<any>(
    "post",
    "/api/admin/config/price/user-template/create-head",
    {
      data,
      headers: {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    }
  );
};
// 更新模板头/api/admin/config/price/user-template/{templateId}/head
export const updateAdminTemplateHead = (
  templateId: string,
  data: {
    title: string;
    description?: string;
  }
) => {
  return http.request<any>(
    "put",
    `/api/admin/config/price/user-template/${templateId}/head`,
    {
      data,
      headers: {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    }
  );
};

// 删除模板头/api/admin/config/price/user-template/{templateId}
export const deleteAdminTemplateHead = (templateId: string) => {
  return http.request<any>(
    "delete",
    `/api/admin/config/price/user-template/${templateId}`
  );
};

//设置模板头-模板项的映射关系/api/admin/config/price/user-template/{templateId}/item-ids
export const setAdminTemplateHeadItemIds = (
  templateId: string,
  data: {
    itemIds: string[];
  }
) => {
  return http.request<any>(
    "put",
    `/api/admin/config/price/user-template/${templateId}/item-ids`,
    { data }
  );
};
// 应用模板到用户/api/admin/config/price/user-template/{templateId}/apply
export const applyAdminTemplateHead = (
  templateId: string,
  data: {
    userId: string | number;
    override?: boolean;
  }
) => {
  return http.request<any>(
    "post",
    `/api/admin/config/price/user-template/${templateId}/apply`,
    {
      params: data
    }
  );
};
// 获取模板头详情/api/admin/config/price/user-template/{templateId}
export const getAdminTemplateHead = (templateId: string) => {
  return http.request<any>(
    "get",
    `/api/admin/config/price/user-template/${templateId}`
  );
};
